<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RocketMQ 消息传递机制深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #4f46e5;
        }
        
        /* 悬挂标点 */
        .hanging-punctuation {
            hanging-punctuation: first last;
        }
        
        /* 卡片悬停效果 */
        .card-hover {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        
        /* 渐变文字效果 */
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        /* 数字标记样式 */
        .number-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 2rem;
            height: 2rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            font-weight: 700;
            margin-right: 0.75rem;
            flex-shrink: 0;
        }
        
        /* 流程图容器样式 */
        .mermaid-container {
            background: white;
            border-radius: 1rem;
            padding: 2rem;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        
        /* 代码块样式 */
        .code-block {
            background: #1e293b;
            color: #e2e8f0;
            padding: 1.5rem;
            border-radius: 0.75rem;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            line-height: 1.6;
        }
        
        /* 滚动动画 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .fade-in-up {
            animation: fadeInUp 0.6s ease-out;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero 区域 -->
    <section class="relative overflow-hidden">
        <div class="absolute inset-0 bg-gradient-to-br from-purple-600 via-indigo-600 to-blue-600 opacity-90"></div>
        <div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-24">
            <div class="text-center fade-in-up">
                <h1 class="text-5xl md:text-6xl font-bold text-white mb-6">
                    RocketMQ 消息传递机制
                    <span class="block text-3xl md:text-4xl mt-4 font-light opacity-90">深度解析</span>
                </h1>
                <p class="text-xl text-white opacity-90 max-w-3xl mx-auto leading-relaxed">
                    探索分布式消息中间件的核心工作原理，深入理解 Producer 与 Consumer 之间的精妙协作
                </p>
                <div class="mt-10 flex justify-center space-x-6">
                    <div class="text-center">
                        <i class="fas fa-paper-plane text-4xl text-white opacity-80"></i>
                        <p class="text-white mt-2">高效发送</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-server text-4xl text-white opacity-80"></i>
                        <p class="text-white mt-2">可靠存储</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-inbox text-4xl text-white opacity-80"></i>
                        <p class="text-white mt-2">灵活消费</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 主要内容区域 -->
    <main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        
        <!-- Producer 发送流程 -->
        <section class="mb-20">
            <div class="text-center mb-12">
                <h2 class="text-4xl font-bold gradient-text mb-4">Producer 发送消息的完整流程</h2>
                <p class="text-gray-600 text-lg">从初始化到消息成功投递的每一个关键步骤</p>
            </div>
            
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                <!-- 步骤卡片 -->
                <div class="card-hover bg-white rounded-xl p-6 shadow-lg">
                    <div class="flex items-start">
                        <span class="number-badge">1</span>
                        <div>
                            <h3 class="text-xl font-semibold text-gray-800 mb-3">启动初始化阶段</h3>
                            <ul class="space-y-2 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>创建并启动 Producer 实例</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>加载配置并初始化内部组件</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>与 NameServer 建立连接，获取 Topic 路由信息</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="card-hover bg-white rounded-xl p-6 shadow-lg">
                    <div class="flex items-start">
                        <span class="number-badge">2</span>
                        <div>
                            <h3 class="text-xl font-semibold text-gray-800 mb-3">消息发送前准备</h3>
                            <ul class="space-y-2 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>创建消息对象（Message），设置 Topic、Tag、Key 等属性</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>根据需要设置消息属性，如延迟级别、事务标识等</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>序列化消息体</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="card-hover bg-white rounded-xl p-6 shadow-lg">
                    <div class="flex items-start">
                        <span class="number-badge">3</span>
                        <div>
                            <h3 class="text-xl font-semibold text-gray-800 mb-3">路由查询与 Broker 选择</h3>
                            <ul class="space-y-2 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>根据 Topic 从本地路由表查询消息队列列表</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>如本地没有路由信息，则从 NameServer 获取并更新</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>根据负载均衡策略选择目标队列</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="card-hover bg-white rounded-xl p-6 shadow-lg">
                    <div class="flex items-start">
                        <span class="number-badge">4</span>
                        <div>
                            <h3 class="text-xl font-semibold text-gray-800 mb-3">消息发送过程</h3>
                            <div class="space-y-3">
                                <p class="text-gray-600">构建发送请求，包含消息内容和元数据</p>
                                <div class="space-y-2">
                                    <div class="bg-purple-50 p-3 rounded-lg">
                                        <p class="font-semibold text-purple-700">同步发送</p>
                                        <p class="text-sm text-gray-600">发送请求并等待 Broker 响应</p>
                                    </div>
                                    <div class="bg-blue-50 p-3 rounded-lg">
                                        <p class="font-semibold text-blue-700">异步发送</p>
                                        <p class="text-sm text-gray-600">发送后立即返回，通过回调处理结果</p>
                                    </div>
                                    <div class="bg-green-50 p-3 rounded-lg">
                                        <p class="font-semibold text-green-700">单向发送</p>
                                        <p class="text-sm text-gray-600">只发送消息，不关心发送结果</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card-hover bg-white rounded-xl p-6 shadow-lg">
                    <div class="flex items-start">
                        <span class="number-badge">5</span>
                        <div>
                            <h3 class="text-xl font-semibold text-gray-800 mb-3">重试机制</h3>
                            <ul class="space-y-2 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-sync-alt text-orange-500 mt-1 mr-2"></i>
                                    <span>当消息发送失败时（如网络异常、Broker 繁忙等）</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-sync-alt text-orange-500 mt-1 mr-2"></i>
                                    <span>根据重试次数配置进行有限次数重试</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-sync-alt text-orange-500 mt-1 mr-2"></i>
                                    <span>如果配置了其他 Broker，会尝试向其发送</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="card-hover bg-white rounded-xl p-6 shadow-lg">
                    <div class="flex items-start">
                        <span class="number-badge">6</span>
                        <div>
                            <h3 class="text-xl font-semibold text-gray-800 mb-3">结果处理</h3>
                            <ul class="space-y-2 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-file-alt text-indigo-500 mt-1 mr-2"></i>
                                    <span>记录发送结果日志</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-chart-line text-indigo-500 mt-1 mr-2"></i>
                                    <span>处理发送统计信息</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-bell text-indigo-500 mt-1 mr-2"></i>
                                    <span>触发相应的成功或失败回调</span>
                                </li>
                            </ul>